<template>
    <div class="navBar">
        <div class="navBar_tit">
            <van-icon name="arrow-left" class="back" @click="backTo"></van-icon>
            <h3>{{tit}}</h3>
            <div class="tit_end">
                <van-icon name="weapp-nav"></van-icon>
                <van-icon name="replay"></van-icon>
            </div>
        </div>
    </div>
</template>

<script>
import { defineComponent,reactive,ref } from 'vue'
import {useRouter} from 'vue-router'
// import routePath from '../../router'
export default defineComponent({
    // 接收上级组件传值
    props:['tit'],
  setup(props,context) {

    console.log(props,'props');
    //   标题默认值
        let tit = ref('标\xa0\xa0\xa0\xa0题');
    //   将接受的参数赋值
        tit=props.tit;

    //   路由
        let router = useRouter();
    
        // console.log(routePath.options.routes,'routes');
    //   跳转路由
        const backTo = () => {

           if(tit === "新\xa0\xa0\xa0\xa0房" || tit === '二\xa0\xa0手\xa0\xa0房' || tit === '出\xa0\xa0租\xa0\xa0房' || tit === '消\xa0\xa0\xa0\xa0息' || tit === '求\xa0\xa0\xa0\xa0购' || tit === '楼\xa0\xa0市\xa0\xa0圈' || tit === '直\xa0\xa0\xa0\xa0播' || tit === '团\xa0\xa0\xa0\xa0购' || tit === '排\xa0\xa0行\xa0\xa0榜' || tit === '战\xa0\xa0\xa0\xa0绩' || tit === '消\xa0\xa0\xa0\xa0息'){
               router.push('/home');
           }else{
                if(localStorage.getItem('House') === '新房'){
                    router.push('/newHouse')
                }else if(localStorage.getItem('House') === '二手房'){
                    router.push('/secondRoom')
                }else if(localStorage.getItem('House') === '出租房'){
                    router.push('/rentOut')
                }
           }
        }
      return {  
        tit,
        backTo    
      }
  },
})
</script>

<style lang='less' scoped>
.navBar{
    width: 100%;
    height: 60px;
    padding: 0 20px;
    background: linear-gradient(
            135deg,
            rgba(2, 114, 240, 1) 0%, 
            rgba(2, 114, 240, 1) 0%, 
            rgba(57, 165, 255, 1) 100%, 
            rgba(57, 165, 255, 1) 100%
        );
    .navBar_tit{
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .back{
            font-size: 16px;
            color: #fff;
        }
        h3{
            flex: 1;
            text-align: right;
            margin-right: 65px;
            color: #fff;
        }
        .tit_end{
            width: 80px;
            height: 30px;
            border: 1px solid #fff;
            padding: 0 12px;
            border-radius: 40px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            i{
                color: #fff;
                font-size: 20px;
            }
        }
    }
}
</style>
